﻿@using UsedBookTradeSystem.Models.Entity
@using UsedBookTradeSystem.Models.Dtos.OutputDtos
@using UsedBookTradeSystem.Models.Enum;
@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    User userinfo = ViewBag.UserInfo;

    var IsMale = userinfo.Gender == GenderEnum.Male;
    var IsFemale = userinfo.Gender == GenderEnum.Female;
    var IsUnknown = userinfo.Gender == GenderEnum.Unknown;

    int index = 0;
}
<section class="py-5 bg-light">
    <div class="container">
        <div class="row px-4 px-lg-5 py-lg-4 align-items-center">
            <div class="col-lg-6">
                <h1 class="h2 text-uppercase mb-0">个人中心</h1>
            </div>
            <div class="col-lg-6 text-lg-end">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb justify-content-lg-end mb-0 px-0 bg-light">
                        <li class="breadcrumb-item"><a class="text-dark" href="/Home/Shop">商城</a></li>
                        <li class="breadcrumb-item active" aria-current="page">个人中心</li>
                    </ol>
                </nav>
            </div>
        </div>
    </div>
</section>
<section class="py-5">
    <!-- BILLING ADDRESS-->
    <h2 class="h5 text-uppercase mb-4">个人信息</h2>
    <div class="row">
        <div class="col-lg-12">
            <form action="/Shopper/UpdateShopper" method="post">
                <input name="Id" value="@userinfo.Id" hidden />
                <div class="row gy-3">
                    <div class="col-lg-6">
                        <label class="form-label text-sm text-uppercase" for="firstName">用户名 </label>
                        <input class="form-control form-control-lg" type="text" id="firstName" name="UserName" value="@userinfo.UserName" placeholder="请输入用户名" readonly>
                    </div>
                    <div class="col-lg-6">
                        <label class="form-label text-sm text-uppercase" for="lastName">电话号码 </label>
                        <input class="form-control form-control-lg" type="text" id="lastName" name="Tel"  value="@userinfo.Tel" placeholder="请输入电话号码">
                    </div>
                    <div class="col-lg-6">
                        <label class="form-label text-sm text-uppercase" for="email">密码 </label>
                        <input class="form-control form-control-lg" type="text" id="email" name="Password" placeholder="请输入密码">
                    </div>
                    <div class="col-lg-6">
                        <label class="form-label text-sm text-uppercase" for="phone">确认密码</label>
                        <input class="form-control form-control-lg" type="text" id="phone" name="ConfirmPassword" placeholder="请重复密码">
                    </div>
                    <div class="col-lg-12">
                        <label class="form-label text-sm text-uppercase" for="address">地址</label>
                        <input class="form-control form-control-lg" type="text" id="address" name="Address" value="@userinfo.Address" placeholder="请输入收货地址">
                    </div>
                    <div class="col-lg-12">
                        <label class="form-label text-sm text-uppercase" for="country">性别</label>
                        <select name="Gender" class="form-control form-control-lg ">
                            <option value="0" selected="@IsMale">男</option>
                            <option value="1" selected="@IsFemale">女</option>
                            <option value="2" selected="@IsUnknown">未知</option>
                        </select>
                    </div>
                    <div class="col-lg-12 form-group">
                        <button class="btn btn-dark" type="submit">确认更改</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>
<section class="py-5">
    <div class="card">
        <div class="card-header">
            <p style="display:inline;vertical-align:middle">订单列表</p>
        </div>
        <table class="table card-table">
            <thead class="thead-light">
                <tr>
                    <th>#</th>
                    <th>订单状态</th>
                    <th>收货地址</th>
                    <th>收货人</th>
                    <th>联系电话</th>
                    <th>总价</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (Order item in ViewBag.OrderList)
                {
                    index++;
                    <tr>
                        <td scope="row" style="vertical-align:middle">@index</td>
                        <td style="vertical-align:middle">
                            @(
                                item.OrderStatus switch
                                {
                                    OrderEnum.paid => "待发货",
                                    OrderEnum.Delivery => "已发货",
                                    OrderEnum.Completed => "已完成",
                                    OrderEnum.Cancel => "已取消",
                                    _ => "未知状态"
                                }
                                )
                        </td>
                        <td style="vertical-align:middle">@item.Address</td>
                        <td style="vertical-align:middle">@item.UserName</td>
                        <td style="vertical-align:middle">@item.Tel</td>
                        <td style="vertical-align:middle">￥@item.Total</td>
                        <td style="vertical-align:middle">
                            @Html.ActionLink("订单详情", "Show", new { id = item.Id }, new { @class = "btn btn-success deleteBtn" })
                            @if (item.OrderStatus == OrderEnum.paid)
                            {
                                @Html.ActionLink("取消订单", "Delete", new { id = item.Id }, new { @class = "btn btn-danger deleteBtn", @onclick = "return confirmDelete();" })
                            }

                        </td>
                    </tr>
                }
                @if (index == 0)
                {
                    <tr>
                        <td colspan="4" style="vertical-align:central;text-align:center;"> 暂无数据 </td>
                    </tr>

                }
            </tbody>
        </table>

    </div>
</section>

